<template>

  <!--  试图-->
  <div>


    <el-dialog title="发货" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="送货备注" :label-width="formLabelWidth">
          <el-input v-model="form.remark" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="选择司机" :label-width="formLabelWidth">
          <el-select v-model="form.driverId" placeholder="请选择司机">
            <el-option v-for="a in driverList" :label="a.driverName" :value="a.driverId" :key="a.driverId" ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="sureDeliver">确 定</el-button>
      </div>
    </el-dialog>



    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="快递单号">
        <el-input clearable v-model="formInline.trackingNumber" placeholder="快递单号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="getLogisticsList">查询</el-button>
      </el-form-item>
    </el-form>


    <el-table
        ref="singleTable"
        :data="tableData"
        highlight-current-row
        style="width: 100%">
      <el-table-column
          fixed
          prop="logisticsId"
          label="物流序号"
          width="150">
      </el-table-column>
      <el-table-column
          prop="orderId"
          label="关联订单编号"
          width="120">
      </el-table-column>
      <el-table-column
          prop="senderName"
          label="发货人姓名"
          width="120">
      </el-table-column>
      <el-table-column
          prop="driverName"
          label="司机表外键"
          width="120">
      </el-table-column>
      <el-table-column
          prop="senderPhone"
          label="发货人电话"
          width="120">
      </el-table-column>
      <el-table-column
          prop="senderAddress"
          label="发货人地址"
          width="120">
      </el-table-column>
      <el-table-column
          prop="receiverName"
          label="收货人姓名"
          width="120">
      </el-table-column>
      <el-table-column
          prop="receiverPhone"
          label="收货人电话"
          width="120">
      </el-table-column>
      <el-table-column
          prop="receiverAddress"
          label="收货人地址"
          width="120">
      </el-table-column>
      <el-table-column
          prop="shippingMethod"
          label="运输方式"
          width="120">
      </el-table-column>
      <el-table-column
          prop="shippingStatus"
          label="物流状态"
          width="120">
      </el-table-column>
      <el-table-column
          prop="trackingNumber"
          label="快递单号"
          width="120">
      </el-table-column>
      <el-table-column
          prop="estimatedDeliveryDate"
          label="预计送达日期"
          width="120">
      </el-table-column>
      <el-table-column
          prop="actualDeliveryDate"
          label="实际送达日期"
          width="120">
      </el-table-column>
      <el-table-column
          prop="deliveryRemark"
          label="送货备注"
          width="120">
      </el-table-column>
      <el-table-column
          prop="createTime"
          label="创建时间"
          width="120">
      </el-table-column>
      <el-table-column
          prop="logisticsProvider"
          label="物流供应商"
          width="120">
      </el-table-column>
      <el-table-column
          prop="argpName"
          label="货物名"
          width="120">
      </el-table-column>
      <el-table-column
          prop="specifications"
          label="规格"
          width="120">
      </el-table-column>
      <el-table-column
          prop="weight"
          label="重量"
          width="120">
      </el-table-column>
      <el-table-column
          prop="goodsNum"
          label="货物数量"
          width="120">
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button @click="openDeliver(scope.row.logisticsId)" type="text" size="small">发货</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
        @current-change="handleCurrentChange"
        :page-size="pageSize"
        layout="total, prev, pager, next"
        :total="total">
    </el-pagination>

  </div>

</template>

<script>
export default {
  name: "LogisticsView",
  data() {
    return {
      //默认属性
      tableData:[],
      pageNum:1,
      pageSize:3,
      total:0,
      dialogFormVisible:false,
      form:{},
      formLabelWidth:'120px',
      driverList:[],
      formInline:{},





    }
  }, methods: {
    //自定义方法

    sureDeliver() {

      this.axios.post("system/logistics/sureLogisticsDeliver", this.form).then(res => {
        if (res.data.code == 200) {
          this.$message.success(res.data.msg);
          this.dialogFormVisible = false;
        } else {
          this.$message.error(res.data.msg);
        }
      });
    },
    getDriverList() {
      this.axios.get("system/listDiriver").then(res => {
        this.driverList = res.data.data
        console.log(res.data.data)
        console.log(this.driverList+"000000000000000000000")
      });
    },
    openDeliver(logisticsId) {
      this.form = {}
      this.getDriverList();
      this.dialogFormVisible = true;
      this.form.logisticsId = logisticsId;
    },
    handleCurrentChange(page) {
      this.pageNum = page;
      this.getLogisticsList();
    },
    getLogisticsList() {
      this.axios.get("system/logistics/getLogisticsList",{params:{pageNum:this.pageNum,pageSize:this.pageSize,
          trackingNumber: this.formInline.trackingNumber}}).then(res => {
        this.tableData = res.data.data.list
        this.total = res.data.data.total
      });
    },

  }, created() {//初始化
      this.getLogisticsList();

  }
}
</script>

<style scoped>

</style>